package com.leenmvc.core.web.controller;

import com.leenmvc.core.annotation.ApiDescription;
import com.leenmvc.core.annotation.Note;
import com.leenmvc.core.utils.PingUtil;
import com.leenmvc.core.base.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: zhousc
 * @Description:
 * @date: 2020/10/09 9:15
 */
@RestController
@ApiDescription("ping工具")
@RequestMapping("system/ping")
public class PingController {

    @GetMapping("pingIp")
    @Note("备份文件导出,导出到本地")
    public Result pingIp(@RequestParam Map<String,Object> map){
        String ip = (String) map.get("ip");
        int count = Integer.parseInt((String) map.get("count"));
            int timeOut = Integer.parseInt((String) map.get("timeOut"));
        boolean ping = PingUtil.ping(ip, count, timeOut);
        return new Result().ok(ping);
    }
}
